# Maintainer: AndyRTR <andyrtr@archlinux.org>

# Contributor: Alexander Rødseth <rodseth@gmail.com>
# Contributor: Mateusz Herych <heniekk@gmail.com>
# Contributor: royrocks <royrocks13@gmail.com>

pkgname=libpaper
pkgver=1.1.28
pkgrel=1
pkgdesc='Library for handling paper characteristics'
arch=('x86_64')
url='https://packages.debian.org/unstable/source/libpaper'
license=('GPL')
depends=('sh' 'run-parts')
backup=('etc/papersize')
#source=("https://debian.org/debian/pool/main/libp/$pkgname/${pkgname}_$pkgver+nmu5.tar.gz") # broken cert
source=("http://ftp.de.debian.org/debian/pool/main/libp/$pkgname/${pkgname}_$pkgver.tar.gz")
sha256sums=('c8bb946ec93d3c2c72bbb1d7257e90172a22a44a07a07fb6b802a5bb2c95fddc')

prepare() {
  cd "$pkgname-$pkgver"
  autoreconf -vfi
}

build() {
  cd "$pkgname-$pkgver"
  ./configure \
    --prefix=/usr \
    --sysconfdir=/etc \
    --sbindir=/usr/bin
  make
}

package() {
  cd "$pkgname-$pkgver"
  make DESTDIR="$pkgdir" install
  
  # add systemwide default papersize read by many office applications
  install -dm 755 "$pkgdir"/etc
  echo '# Simply write the paper name. See papersize(5) for possible values' > "$pkgdir"/etc/papersize

  # add libpaper.d directory other packages can use to store files
  install -dm 755 "$pkgdir"/etc/libpaper.d

  # add localisation
  pushd debian/po
  for i in `ls *.po`; do
	install -dm 755 "${pkgdir}"/usr/share/locale/${i%.po}/LC_MESSAGES/;
	msgfmt $i -o "${pkgdir}"/usr/share/locale/${i%.po}/LC_MESSAGES/${pkgname}.mo;
  done
  popd
}
